<!DOCTYPE html>
<head>
    <#assign dicSelect=JspTaglibs["http://www.casic304.cn/dicSelect"] />
    <#assign secSelect=JspTaglibs["http://www.casic304.cn/secSelect"] />
    <#assign fillDept=JspTaglibs["http://www.casic304.cn/fillDept"] />

    <meta charset="utf-8">
    <title>QC小组注册基本信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <!--<link rel="stylesheet" href="/qbdmsStatic/style/forms/currencyCss.css">-->
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">

    <link rel="stylesheet" href="${ctx}/qbdmsStatic/public/ztree/zTreeStyle.css"/>
    <script src="${ctx}/qbdmsStatic/public/ztree/jquery.min.js"></script>
    <script src="${ctx}/qbdmsStatic/public/ztree/jquery.ztree.all.min.js"></script>
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
    <style>
        .selectorLabel{
            display: block;
            height: 38px;
            line-height: 38px;
            width: 100%;
            text-overflow:ellipsis;
            white-space:nowrap;
            overflow:hidden;
        }
        .selectorCont{
            float: left;
            width: 100%;
        }
        .selectorCont button{
            float: right;
            margin-top: 3px;
        }

        .selectorCont .selectorInfo{
            margin-right: 60px;
        }
        .selectorSearchBtn{
            position: absolute;
            right: 125px;
            top: 13px;
        }

        .form-pop-selector .layui-layer-btn0,.form-pop-selector .layui-layer-btn1,.form-pop-selector .layui-layer-btn2{
            color: #fff;
            white-space: nowrap;
            text-align: center;
            font-size: 14px;
            border: none;
            border-radius: 2px;
            height: 38px;
            line-height: 38px;
            cursor: pointer;

        }
        .form-pop-selector .layui-layer-btn0,.form-pop-selector .layui-layer-btn1{
            background-color: #009688;
        }
        .form-pop-selector .layui-layer-btn2{
            background-color: #FF5722;
        }




    </style>
</head>
<body class="listBody">
<div class="qbdms-bodyDiv">
    <div class="layui-table-view-body qbdms-add-view-body">
        <form class="layui-form" requrl="${ctx}/qbdms/wQbdQcGroup/get" lay-filter="wQbdQcGroupDataForm" id="wQbdQcGroupDataForm">
            <div class="qbdms-formTitle">QC小组注册<i class="qbdms-returnOn closeWindow" id="back">返回</i></div>
            <div class="qbdms-formBody">
            <@fillDept.dept id="tbxx"/>
            <div class="layui-row">
                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="密级">密级<span style="color: red;">*</span></label>
                    <div class="layui-input-block qbdms-input">
                        <@secSelect.sec_select data_src=1 required=true name="secret"/>
                    </div>
                </div>

                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="QC小组名称">QC小组名称<span style="color: red;">*</span></label>
                    <div class="layui-input-block qbdms-input">
                        <input type="text" name="groupname" lay-reqtext="QC小组名称是必填项" placeholder="请输入"
                               autocomplete="off" class="layui-input  textInput" maxlength="80" lay-verify="required">
                    </div>
                </div>

                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="注册单位">注册单位<span
                            style="color: red;">*</span></label>
                    <div class="layui-input-block qbdms-input">
                        <input type="text" name="registerdept" readonly="readonly" placeholder="请输入"
                               autocomplete="off" class="layui-input  textInput"
                               lay-reqtext="注册单位是必填项" maxlength="100" lay-verify="required">
                    </div>
                </div>

                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="注册编号">注册编号</label>
                    <div class="layui-input-block qbdms-input">
                        <input type="text" name="registernum"
                               autocomplete="off" class="layui-input  textInput" maxlength="7" id="registernum" disabled>
                    </div>
                </div>

                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="QC小组名称">课题名称<span style="color: red;">*</span></label>
                    <div class="layui-input-block qbdms-input">
                        <input type="text" name="subjectname" lay-reqtext="课题名称是必填项" placeholder="请输入"
                               autocomplete="off" class="layui-input  textInput" maxlength="80" lay-verify="required">
                    </div>
                </div>

                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="注册时间">注册时间<span
                            style="color: red;">*</span></label>
                    <div class="layui-input-block qbdms-input">
                        <input type="text" name="registerdate" placeholder="请选择" readonly="readonly"
                               autocomplete="off" class="layui-input dateTimeFiled input-right time-init"
                               lay-reqtext="注册时间是必填项" maxlength="50" lay-verify="required">
                    </div>
                </div>

                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="计划完成时间">计划完成时间</label>
                    <div class="layui-input-block qbdms-input">
                        <input type="text" name="finishdate" placeholder="请选择" readonly="readonly"
                               autocomplete="off" class="layui-input dateTimeFiled input-right time-init"
                               lay-reqtext="计划完成时间是必填项" maxlength="50">
                    </div>
                </div>


                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="组长">组长</label>
                    <!--       <div class="selectorCont" >
                               <div class="selectorInfo">-->
                    <button type="button" typeid="4" class="layui-btn qbdms-twoBtn selectorBtn">选择</button>
                    <div class="layui-input-block qbdms-input qbdms-inputIsButton">
                        <input type="text" name="groupleader" readonly="readonly" placeholder="请选择"
                               autocomplete="off" class="layui-input  selectorInput"
                               maxlength="30" fieldname="groupleader">
                        <input type="hidden" name="groupleaderid" placeholder="组长ID"
                               autocomplete="off" class="layui-input  textInput getIds"
                               maxlength="100" fieldname="registerdeptid">
                    </div>
                </div>

                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="小组成员">小组成员</label>
                    <button type="button" typeid="8" class="layui-btn qbdms-twoBtn selectorBtn">选择</button>
                    <div class="layui-input-block qbdms-input qbdms-inputIsButton">
                        <input type="text" name="groupMembers" placeholder="请选择"
                               autocomplete="off" class="layui-input  selectorInput"
                               maxlength="500" fieldname="groupMembers" readonly>
                        <input type="hidden" name="groupmembersid" placeholder="请输入小组成员ID"
                               autocomplete="off" class="layui-input  textInput getIds"
                               fieldname="registerdeptid">
                    </div>
                </div>

                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="小组类别">小组类别</label>
                    <div class="layui-input-block qbdms-input">
                        <@dicSelect.dic name="groupCategory" reqtext="小组类别是必填项" nodeKey="xzlb" />
                    </div>
                </div>

                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="人数">人数</label>
                    <div class="layui-input-block qbdms-input">
                        <input type="text" name="peopleamount" placeholder="请输入" autocomplete="off"
                               class="layui-input textInput" lay-verify="num" maxlength="10">
                    </div>
                </div>

                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="联系人">联系人</label>
                    <button type="button" typeid="4" class="layui-btn qbdms-twoBtn selectorBtn">选择</button>
                    <div class="layui-input-block qbdms-input qbdms-inputIsButton">
                        <input type="text" name="linkman" placeholder="请选择"
                               autocomplete="off" class="layui-input  selectorInput"
                               maxlength="30" fieldname="linkman" readonly>
                        <input type="hidden" name="linkmanid" placeholder="联系人ID"
                               autocomplete="off" class="layui-input  textInput getIds"
                               maxlength="100" fieldname="linkmanid">
                    </div>
                </div>

                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="联系电话">联系电话</label>
                    <div class="layui-input-block qbdms-input">
                        <input type="text" name="linktel" placeholder="请输入"
                               autocomplete="off" class="layui-input  textInput" lay-verify="numberOfPhone"
                               maxlength="11" fieldname="linktel">
                    </div>
                </div>

                <div class="qbdms-oneForm  ">
                    <label class="layui-form-label qbdms-label" title="带来的经济效益（万元）">带来的经济效益（万元）</label>
                    <div class="layui-input-block qbdms-input">
                        <input type="text" name="economicPerformance" placeholder="请输入"
                               autocomplete="off" class="layui-input  textInput" lay-verify="money"
                               maxlength="50" fieldname="economicPerformance" id="money">
                    </div>
                </div>

                <div class="qbdms-textarea  ">
                    <label class="layui-form-label qbdms-label">目标及预期效果</label>
                    <div class="layui-input-block qbdms-input">
                           <textarea name="targeteffect" placeholder="请输入" rows="2"
                                     autocomplete="off" class="layui-textarea" maxlength="300"></textarea>
                    </div>
                </div>

                <div class="qbdms-textarea  ">
                    <label class="layui-form-label qbdms-label">备注</label>
                    <div class="layui-input-block qbdms-input">
                        <textarea name="remark" rows="2" placeholder="请输入" autocomplete="off" class="layui-textarea"
                                  maxlength="300" fieldname="remark"></textarea>
                    </div>
                </div>
                <#if flag =="1" && flowStatus =="3">
                <div class="qbdms-textarea  ">
                    <label class="layui-form-label qbdms-label">研究室主管领导审批</label>
                    <div class="layui-input-block qbdms-input">
                        <#list taskOpinionNewList as taskOpinionNewList>
                            <#if taskOpinionNewList.taskName == "研究室主管领导审批">
                                <p>${taskOpinionNewList.opinion}</p><br/>
                                <p style="text-align:right;">审批人:${taskOpinionNewList.exeFullname}&nbsp&nbsp&nbsp&nbsp
                                    日期:${(taskOpinionNewList.endTime?string("yyyy-MM-dd"))!}</p>
                            </#if>
                        </#list>
                    </div>
                </div>
                <div class="qbdms-textarea  ">
                    <label class="layui-form-label qbdms-label">质量综合助理确定</label>
                    <div class="layui-input-block qbdms-input">
                    <#list taskOpinionNewList as taskOpinionNewList>
                        <#if taskOpinionNewList.taskName == "质量综合助理确定">
                            <p>${taskOpinionNewList.opinion}</p><br/>
                            <p style="text-align:right;">审批人:${taskOpinionNewList.exeFullname}&nbsp&nbsp&nbsp&nbsp
                                日期:${(taskOpinionNewList.endTime?string("yyyy-MM-dd"))!}</p>
                        </#if>
                    </#list>
                    </div>
                </div>
                </#if>

                <div class="layui-hide">
                    <input type="text" name="id" placeholder="请输入"
                           autocomplete="off" class="layui-input  textInput"
                           maxlength="50" fieldname="id">
                    <input type="text" name="registerdeptid" placeholder="请输入注册部门ID"
                           autocomplete="off" class="layui-input  textInput"
                           maxlength="50" fieldname="registerdeptid">
                </div>
            </div>

            <div class="layui-form-item btnformItem">
                <p>
                    <span id="hideAndShow" style="display: none;">
                        <a lay-submit lay-filter="wQbdQcGroup" class="layui-btn btn-n privateSubmit qbdms-oneBtn" requrl="${ctx}/qbdms/wQbdQcGroup/save" id="urlFormSave">保存</a>
                        <a lay-filter="wProblemresetMsg" id="run" class="layui-btn btn-n qbdms-oneBtn">启动</a>
                        <button type="reset" id="closeWindow" style="margin-left: 10px;" class="layui-btn layui-btn-sm btn-save qbdms-oneBtnLine">取消</button>
                    </span>
                </p>
            </div>
            </div>
        </form>
    </div>
</div>
</form>
</div>
<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>

<script>
    var vaildFlag ;
    var runFlag=false;
    var flowStatus="${flowStatus}";
    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','setter', 'laydate', 'jquery','commonDialog', 'common','publicMethods','qbdmsForm','propsHandle'], function () {
        var laydate = layui.laydate;
        var setter = layui.setter;
        var $ = layui.jquery;
        var common = layui.common;
        var commonDialog = layui.commonDialog;
        var propsHandle = layui.propsHandle;
        var publicMethods = layui.publicMethods;
        var dateTimeFiledLen = $(".dateTimeFiled");
        var form = layui.qbdmsForm;

        for (var i = 0; i < dateTimeFiledLen.length; i++) {
            laydate.render({
                elem: dateTimeFiledLen[i] //指定元素
                , type: 'date'
                , trigger: 'click'
            });
        }

        var defProps = {
                viewMould: 'moulds/', // 组件模块 存放文件 *****
                initCss: [
                    // 'style/forms/grid/grid1',
                    // 'style/forms/grid/grid2',
                    // 'style/forms/grid/grid3',
                    // 'style/forms/template/tag',
                    // 'style/forms/template/text',
                    // 'style/forms/template/table',
                    // 'style/forms/template/textArea',
                    // 'style/forms/template/radioOption',
                    // 'style/forms/template/date',
                    // 'style/forms/template/button',
                    // 'style/forms/template/uploadFile',
                    // 'style/forms/template/richText',
                    // 'style/forms/template/select',
                    // 'style/forms/template/checkOption',
                    // 'style/forms/template/dataLexi',
                    // 'style/forms/template/uploadImg',
                    // 'style/forms/template/selector',
                    // 'style/forms/formDevise',
                    // 'style/forms/dragLay',
                    // 'style/forms/formPreview'
                ],// formAreaInfo:'.formPreview',
                formAreaInfo: 'html',
                temDate: '.temDate',
                uploadFileBtn: '.uploadFileBtn',
                uploadImgBtn: '.uploadImgBtn',
                richTextArea: '.richTextArea',
                selectInput: '.selectInput',
                radioOptionCont: '.radioOptionCont',
                dataLexiTree: '.dataLexiTree',
                selectorBtn: '.selectorBtn'
            },
            temQuery = new propsHandle()  // 实例化模板功能部分
        ;


        // 初始化模板功能
        temQuery.initTem({
            selectorBtn: defProps.selectorBtn,
            selectorTemPath: setter.views + defProps.viewMould
        });

        if("${roleAlias}"=="bpm_zlzhzly") {
            $(".subContTem").hide();
            $(".qbdms-SubTableTitle").hide();
            $(".qbdms-tableDiv").hide();
        }

        vaildFlag = false;
        $("#urlFormSave").click(function () {
            vaildFlag=form.VerifyForm("wQbdQcGroupDataForm");
        });

        //关闭当前页面
        $("#closeWindow,.closeWindow").click(function () {
            window.location.href = serverPath.qbdmsPath  + '/qbdms/wQbdQcGroup/view/list';
        });


        var id = "${id}";
        // 注册单位为当前单位
        if (id == null || id == '') {
            $("input[name='registerdept']").val('${filldept}');
            $("input[name='registerdeptid']").val('${filldeptid}');
        }

        if(flowStatus == null || flowStatus == 0|| flowStatus==99){
            $("#hideAndShow").show();
        }else{
            $("#back").hide();
        }
        if(flowStatus==99){
            $("#run").hide();
        }


        form.verify({
            num: function (value,item) {
                // 如果值为空，不触发校验
                if (value && !new RegExp(/^[1-9]\d*$/).test(value)) return common.verifyTitleAdd(item)+ "只能输入非负整数";
            },
            numberOfPhone: function (value,item) {
                if (value && !new RegExp(/0?(13|14|15|17|18|19)[0-9]{9}/).test(value) && !new RegExp(/^([0-9]{1,6}[-]?)?([0][1-9][0-9]{1,2}[-]?)?[0-9]{6,8}$/).test(value)) return  common.verifyTitleAdd(item)+"请输入正确的电话";
            },
            money: function (value,item) {
                if (value && !new RegExp(/^((0\.\d{1,4})|([1-9]\d*\.\d{1,4})|([1-9]+\d*)|0)$/).test(value)) {
                    return  common.verifyTitleAdd(item)+'请输入数字且小数最多四位';
                }
            }
        });
        var index = parent.layer.getFrameIndex(window.name);
        common.updateForm({
            name: 'wQbdQcGroupDataForm',
            idValue: "${id}",
            primary: "id",
            getCallback: function (data) {
                $("input[name='groupMembers']").attr("ids", data.data.groupmembersid);
                $("input[name='groupleader']").attr("ids", data.data.groupleaderid);
                $("input[name='linkman']").attr("ids", data.data.linkmanid);
                var registernum="${num}";
                console.log(registernum);
                console.log(registernum != "" && registernum != null && registernum != undefined);
                if(registernum != "" && registernum != null && registernum != undefined && "${roleAlias}"=="bpm_zlzhzly"){
                    $("#registernum").removeAttr("disabled");
                    data.data.registernum=registernum;
                }
            },
            updateCallback: function (data) {
                if((flowStatus==0||flowStatus==""||null==flowStatus)&&runFlag==true){
                    run(data.data.id);
                }
                if (common.filterRecord(data)) {
                    if ($(".privateSubmit")) {
                        $(".privateSubmit").attr("disabled", false).css("pointer-events", "auto");
                    }
                    if((flowStatus=="0" || flowStatus==null||flowStatus==""||flowStatus=="99")&&runFlag==false) {
                        layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdQcGroup/view/list';
                        });
                    }
                } else {
                    layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'}, function (index) {
                        layer.close(index);
                        window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdQcGroup/view/list';
                    });
                }
                runFlag=false;
                return false;
            }
        });

        $("#run").click(function () {
            var flag=form.VerifyForm("wQbdQcGroupDataForm");
            if(flag==false){
                return false;
            }
            runFlag=true;
            $("#urlFormSave").click();
        })
        function run(id) {
            var id = id;
            var secret = $("input[name='secret']").val();
            var fillman = $("input[name='fillman']").val();
            var fillmanaccount = $("input[name='fillmanaccount']").val();
            var filldept = $("input[name='filldept']").val();
            var filldeptid = $("input[name='filldeptid']").val();
            var reportStatus = $("input[name='reportStatus']").val();
            var returnmsg = $("input[name='returnmsg']").val();
            var filldepthospital = $("input[name='filldepthospital']").val();
            var filldepthospitalid = $("input[name='filldepthospitalid']").val();
            var reportDate = $("input[name='reportDate']").val();
            var tenantId = $("input[name='tenantId']").val();
            var createBy = $("input[name='createBy']").val();
            var createTime = $("input[name='createTime']").val();
            var updateBy = $("input[name='updateBy']").val();
            var updateTime = $("input[name='updateTime']").val();
            var belongdeptname = $("input[name='belongdeptname']").val();
            var reportReason = $("input[name='reportReason']").val();
            var filldate = $("input[name='filldate']").val();
            var groupname = $("input[name='groupname']").val();
            var registernum = $("input[name='registernum']").val();
            var registerdate = $("input[name='registerdate']").val();
            var registerdept = $("input[name='registerdept']").val();
            var subjectname = $("input[name='subjectname']").val();
            var finishdate = $("input[name='finishdate']").val();
            var groupleader = $("input[name='groupleader']").val();
            var groupMembers = $("input[name='groupMembers']").val();
            var peopleamount = $("input[name='peopleamount']").val();
            var linktel = $("input[name='linktel']").val();
            var economicPerformance = $("input[name='economicPerformance']").val();
            var targeteffect = $("input[name='targeteffect']").val();
            var remark = $("input[name='remark']").val();
            var registerdeptid = $("input[name='registerdeptid']").val();
            var linkman = $("input[name='linkman']").val();
            var groupCategory = $("input[name='groupCategory']").val();
            var groupMembersId = $("input[name='groupMembersId']").val();
            var groupleaderId = $("input[name='groupleaderId']").val();
            var subjectnameId = $("input[name='subjectnameId']").val();
            var linkmanId = $("input[name='linkmanId']").val();
            var flowStatus = $("input[name='flowStatus']").val();
            var nowData = {"id": id,"secret": secret,"fillman": fillman,"fillmanaccount": fillmanaccount,"filldept": filldept,"filldeptid": filldeptid,"reportStatus": reportStatus,"returnmsg": returnmsg,"filldepthospital": filldepthospital,"filldepthospitalid": filldepthospitalid,"reportDate": reportDate,"tenantId": tenantId,"createBy": createBy,"createTime": createTime,"updateBy": updateBy,"updateTime": updateTime,"belongdeptname": belongdeptname,"reportReason": reportReason,"filldate": filldate,"groupname": groupname,"registernum": registernum,"registerdate": registerdate,"registerdept": registerdept,"subjectname": subjectname,"finishdate": finishdate,"groupleader": groupleader,"groupMembers": groupMembers,"peopleamount": peopleamount,"linktel": linktel,"economicPerformance": economicPerformance,"targeteffect": targeteffect,"remark": remark,"registerdeptid": registerdeptid,"linkman": linkman,"groupCategory": groupCategory,"groupMembersId": groupMembersId,"groupleaderId": groupleaderId,"subjectnameId": subjectnameId,"linkmanId": linkmanId,"flowStatus": flowStatus};
            $.ajax({
                url:"${ctx}/qbdms/wQbdQcGroup/run",
                type: "post",
                dataType: 'json',
                contentType : 'application/json',
                data: JSON.stringify(nowData),
                success : function (data) {
                    if (common.filterRecord(data)) {
                        layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdQcGroup/view/list';
                        });
                    } else {
                        layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdQcGroup/view/list';
                        });
                    }
                    return false;
                },
                error : function (XMLHttpRequest, textStatus, errorThrown) {
                    layer.alert(publicMethods.confirmStyle("内容已保存，启动失败"),{title: false,skin: 'confirm-class'}, function (index) {
                        layer.close(index);
                        window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdQcGroup/view/list';
                    });
                }
            })
        }
    });
</script>
</body>
</html>